package edu.bu.cs673.superkids123.parents.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import edu.bu.cs673.superkids123.common.model.Child;

@Entity
@Table(name="theme")
public class SystemTheme {

	/**
	 * @author Abdelghani Bhalla
	 */
	@Id @GeneratedValue
	@Column(name="ThemeID")
	private int id;
	
	@Column(name="ThemeName")
	private String name;
	
	@Column(name="ThemeFont")
	private String font;
	
	@Column(name="ThemeDescription")
	private String description;
	
	@ManyToOne(cascade=CascadeType.ALL)
	@NotFound(action=NotFoundAction.IGNORE)
	@JoinColumn(name="DefaultSoundID")
	private Sound sound;
	
	@ManyToOne(cascade=CascadeType.ALL)
	@NotFound(action=NotFoundAction.IGNORE)
	@JoinColumn(name="DefaultColorID")
	private Color color;
	
	@OneToMany(mappedBy="systemTheme", fetch=FetchType.EAGER)
	private Set<Child> children = new HashSet<Child>();
	
	 
	public Set<Child> getChildren() {
		return children;
	}
	public void setChildren(Set<Child> children) {
		this.children = children;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getFont() {
		return font;
	}
	public Sound getSound() {
		return sound;
	}
	public void setSound(Sound sound) {
		this.sound = sound;
	}
	public Color getColor() {
		return color;
	}
	public void setColor(Color color) {
		this.color = color;
	}
	public void setFont(String font) {
		this.font = font;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public void addChild(Child c)
	{
		c.setSystemTheme(this);
		children.add(c);
	}
	
	public SystemTheme(String name, String font, String description)
	{
		this.name = name;
		this.font = font;
		this.description = description;
	}
	public SystemTheme()
	{
	}
	
}
